<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />

    <style type="text/css">
        .class-title {
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            font-size: 20px;
            font-weight: bold;
            color: #00BFFF;
        }

        .class-hr {
            margin-top: 5px;
            height: 1px;
            border: none;
            border-top: 1px solid #DCDCDC;
        }

        .class-seqno {
            margin-top: 3px;
            margin-left: 10px;
            margin-right: 25px;
            font-size: 10px;
            color: #808080;
            font-weight: bold;
            text-align: right;
        }

        .class-table {
            width: 100%;
            text-align: left;
            color: black;
            font-size: 13px;
            margin-left: 2%;
            width: 100%;
            table-layout: fixed;
        }

        .class-td {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            材料检测单处理
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:60px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">检测单</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择检测单" id="chkBillCode" readonly="true"
                            onclick="goSelectChkBill()" />
                    </div>
                    <!-- <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectChkBill()"></i> -->
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">检测类型</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="chkTypeName" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">物料号</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="mrlCode" readonly>
                    </div>
                    <div class="aui-btn aui-btn-info" style="width:20%;" onclick="copy()">复制</div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">物料名</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="mrlName" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">批次号</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="lotCode" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">生产数量</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="actualQty" disabled="true"> 
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">批次总数</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="nactualQty" disabled="true"> 
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">抽检数量</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="cjqty" disabled="true"> 
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">供应商</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="supplierName" disabled="true"> 
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="width:60%">是否加严管理</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="isTightened" disabled="true"> 
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="width:70%">结束加严管理日期</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="tightenedEndDate" disabled="true"> 
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">检测等级</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="ext07_k" disabled="true"> 
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">审核状态</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="state" disabled="true"> 
                    </div>
                </div>
            </li>
            
        </ul>
    </div>

    <div class='aui-btn aui-btn-info aui-btn-block' style="margin-top:10px;" onclick='citemChkBill()'>进入抽检物料处理页面</div>

    <div class='aui-btn aui-btn-info aui-btn-block' style="margin-top:10px;" onclick='closeChkBill()'>进入检测单关闭界面</div>

    <div id="divhtml" style="display: block;width:100%;overflow-y: scroll;margin-top:10px;"></div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    var chkBillType = ""; //检测单类型
    var id = "";
    var code = "";
    var mrlCode = "";
    var mrlName = "";
    var opCode = "";
    var opName = "";
    var chkTypeName = "";
    var supplierName = "";
    var lotCode = "";
    var actualQty = "";
    var cjqty = "";
    var isTightened = "";
    var tightenedEndDate = "";
    var ext07_k = "";
    var state = "";
    var nactualQty = "";
    apiready = function () {
        id = api.pageParam.id;
        code = api.pageParam.code;
        mrlCode = api.pageParam.mrlCode;
        mrlName = api.pageParam.mrlName;
        opCode = api.pageParam.opCode;
        opName = api.pageParam.opName;
        chkTypeName = api.pageParam.chkTypeName;
        supplierName = api.pageParam.supplierName;
        lotCode = api.pageParam.lotCode;
        actualQty = api.pageParam.actualQty;
        cjqty = api.pageParam.cjqty;
        isTightened = api.pageParam.isTightened;
        tightenedEndDate = api.pageParam.tightenedEndDate;
        ext07_k = api.pageParam.ext07_k;
        state = api.pageParam.state;
        nactualQty = api.pageParam.nactualQty;

        $("#chkBillCode").val(code);
        $("#mrlCode").val(mrlCode);
        $("#mrlName").val(mrlName);
        $("#chkTypeName").val(chkTypeName);
        $("#supplierName").val(supplierName);
        $("#lotCode").val(lotCode);
        $("#actualQty").val(actualQty);
        $("#cjqty").val(cjqty);
        $("#isTightened").val(isTightened);
        $("#tightenedEndDate").val(tightenedEndDate);
        $("#ext07_k").val(ext07_k);
        $("#state").val(state);
        $("#nactualQty").val(nactualQty);
        //chkBillType = '1';
    };

    //选择检测单
    function goSelectChkBill() {
        api.openWin({
            name: 'qcmSelectChkBill_ll',
            url: 'qcmSelectChkBill_ll.html',
            pageParam: {
                processState: "0", //审核状态：0未处理，3处理中，7已处理，8已确认，9已取消
                chkBillType: chkBillType,
                name: "qcmChkBillCl_ll",
            }
        });
    }

    //检测单选择后回调函数
    function setChkBill(id, code, mrlCode, mrlName, opCode, opName, chkTypeName, supplierName, lotCode, actualQty, cjqty, isTightened, tightenedEndDate, ext07_k,state,nactualQty) {
        $("#chkBillCode").val(code);
        $("#mrlCode").val(mrlCode);
        $("#mrlName").val(mrlName);
        $("#chkTypeName").val(chkTypeName);
        $("#supplierName").val(supplierName == 'null' ? '' : supplierName);
        $("#lotCode").val(lotCode == 'null' ? '' : lotCode);
        $("#actualQty").val(actualQty == 'null' ? '' : actualQty);
        $("#cjqty").val(cjqty == 'null' ? '' : cjqty);
        $("#isTightened").val(isTightened == 'null' ? '' : isTightened);
        $("#tightenedEndDate").val(tightenedEndDate == 'null' ? '' : tightenedEndDate);
        $("#ext07_k").val(ext07_k == 'null' ? '' : ext07_k);
        $("#state").val(state == 'null' ? '' : state);
        $("#nactualQty").val(nactualQty == 'null' ? '' : nactualQty);
    }

    //检测项处理完回调函数
    function setChkBillState(processState) {
        console.log("1234")
        if(processState != undefined && processState != null && processState != ""){
            $("#state").val(processState == 'null' ? '' : processState);
        }
       
    }
    //处理
    function deal(chkBillDetailsId) {
        var chkBillCode = $("#chkBillCode").val();

        api.openWin({
            name: 'qcmChkBillDeal',
            url: 'qcmChkBillDeal.html',
            pageParam: {
                chkBillDetailsId: chkBillDetailsId,
                chkBillCode: chkBillCode,
                name: "qcmChkBillCl_ll",
            }
        });
    }

    //进入检测单关闭界面
    function closeChkBill() {
        var chkBillCode = $("#chkBillCode").val();

        if (chkBillCode == null || chkBillCode == "" || chkBillCode == undefined) {
            api.toast({
                msg: "请选择检测单",
                duration: 3000
            });
            return;
        }
        var state = $("#state").val();

        if(state == "未处理" || state == "处理中"){
            api.toast({
                msg: "检测项还未处理,无法关闭检测单!",
                duration: 3000
            });
            return;
        }
        api.openWin({
            name: 'qcmChkBillClose_ll',
            url: 'qcmChkBillClose_ll.html',
            pageParam: {
                chkBillCode: chkBillCode,
                name: "qcmChkBillCl_ll",
                nameQ: "qcmSelectChkBill_ll",
            }
        });
    }

    function citemChkBill(){
        var chkBillCode = $("#chkBillCode").val();
        var mrlCode = $("#mrlCode").val();
        var actualQty = $("#actualQty").val();
        if (chkBillCode == null || chkBillCode == "" || chkBillCode == undefined) {
            api.toast({
                msg: "请选择检测单",
                duration: 3000
            });
            return;
        }

        api.openWin({
            name: 'qcmChkBillCl_citem_ll',
            url: 'qcmChkBillCl_citem_ll.html',
            pageParam: {
                chkBillCode: chkBillCode,
                mrlCode: mrlCode,
                actualQty: actualQty,
                name: "qcmChkBillCl_ll",
                nameQ: "qcmSelectChkBill_ll",
            }
        });
    }
    //清空
    function reset() {
        // $api.html($api.byId("divhtml"), "");
        // $("#chkBillCode").val("");
        // $("#mrlCode").val("");
        // $("#mrlName").val("");
        // $("#chkTypeName").val("");
        // $("#lotCode").val("");
        // $("#actualQty").val("");
        // $("#cjqty").val("");
        // $("#supplierName").val("");
        // $("#isTightened").val("");
        // $("#tightenedEndDate").val("");
        // $("#ext07_k").val("");
        // $("#state").val("");
        // $("#nactualQty").val("");

        api.closeWin();
        var name = api.pageParam.name;
        api.execScript({
            name: name,
            script: 'doSearch()'
        });
    }

    function copy() {
        // 获取输入框元素
        var copyText = document.getElementById("mrlCode");
        // 临时移除readonly属性以便选中文本
        copyText.removeAttribute("readonly");
        // 选中输入框的文本
        copyText.select();
        copyText.setSelectionRange(0, 99999); // 对于移动设备的兼容

        // 执行复制命令
        document.execCommand("copy");
        
        // 重新设置readonly属性以保持其不可编辑状态
        copyText.setAttribute("readonly", "");
        api.toast({
            msg: "复制成功！",
            duration: 3000
        });
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>